function MinCoinChange(coins) {
  var coins = coins; //{1} 
  this.makeChange = function (amount) {
    var change = [],
      total = 0;
    for (var i = coins.length; i >= 0; i--) { //{2} 
      var coin = coins[i];
      while (total + coin <= amount) { //{3} 
        change.push(coin); //{4} 
        total += coin; //{5} 
      }
    }
    return change;
  };
}
// 大部分情况的结果是最优的，不过对有些面额而言，
// 结果不会是最优的

var minCoinChange = new MinCoinChange([1, 5, 10, 25]); 
console.log(minCoinChange.makeChange(36));